#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5;
int Q,n;
struct sss {
	int x,y,val;
	friend bool operator>(sss x,sss y) {
		return x.val<y.val;
	}
	friend bool operator<(sss x,sss y) {
		return x.val>y.val;
	}
} ;
priority_queue<sss> q;
struct tree {
	int l,r,id,ls,rs,tag;
} tre[N];
int root,root1,root2,roott;
bool out[N];
void split(int now,int k,int &lt,int &rt) {
	if(now==0) {
		lt=rt=0;
		return ;
	}
	if(tre[now].l<=k) {
		lt=now;
		split(tre[now].rs,k,tre[now].rs,rt);
	} else {
		rt=now;
		split(tre[now].ls,k,lt,tre[now].ls);
	}
}
int merge(int lt,int rt) {
	if(lt==0||rt==0) return lt+rt;
	if(tre[lt].tag<tre[rt].tag) {
		tre[lt].rs=merge(tre[lt].rs,rt);
		return lt;
	} else {
		tre[rt].ls=merge(lt,tre[rt].ls);
		return rt;
	}
}
signed main() {
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	srand(time(0));
	cin>>Q;
	int cnt=0;
	int l,r;
	char opt;
	while(Q--) {
		cin>>opt>>l>>r;
		if(opt=='A') {
			++cnt;
			split(root,l,root1,root2);
			int o1=root1,o2=root2;
			while(tre[o1].rs) o1=tre[o1].rs;
			while(tre[o2].ls) o2=tre[o2].ls;
			if(o1) q.push({tre[o1].id,cnt,r-tre[o1].l});
			if(o2) q.push({cnt,tre[o2].id,tre[o2].r-l});
			tre[++n]={l,r,cnt,0,0,rand()};
			root=merge(merge(root1,n),root2);
		} else {
			split(root,l,root1,root2);
			split(root1,l-1,root1,roott);
			out[tre[roott].id]=1;
			root=merge(root1,root2);
		}
		while(!q.empty()&&(out[q.top().x]||out[q.top().y])) q.pop();
		if(q.empty()) {
			cout<<tre[root].r-tre[root].l<<"\n";
		} else cout<<q.top().val<<"\n";
	}
	return 0;
}
/*
 */
